﻿#region  
//=====================================================
// 文件名: ObjectManager                
// 创建者: #AuthorName#                
// 创建时间: #CreateTime#              	
// Email: #AuthorEmail#               
// 描述: 当前脚本的功能              
// 修改者列表: 修改者名字以及修改功能      
// 版权所有: #Copyright#                 
//======================================================
#endregion 



using System.Collections.Generic;
using FrameWork.ObjectPool;
using System;
using UnityEngine;

namespace FrameWork
{
    public class ObjectManager : Singleton<ObjectManager>
    {
        private readonly Dictionary<Type, object> m_ObjectPoolDic = new Dictionary<Type, object>();

        public CalssObjectPool<T> GetOrCreateObjectPool<T>(int _maxCount) where T : class, new()
        {
            Type type = typeof(T);
            if (!m_ObjectPoolDic.TryGetValue(type, out object outObj) || outObj == null)
            {
                CalssObjectPool<T> defaultCalssObjectPool = new CalssObjectPool<T>(_maxCount);
                m_ObjectPoolDic.Add(type, defaultCalssObjectPool);
                return defaultCalssObjectPool;
            }
            return outObj as CalssObjectPool<T>;
        }
    }
}